package com.ssy.lingxi.pay.serviceimpl.eAccount;

import com.ssy.lingxi.pay.entity.eAccount.EAccountStatusRecord;
import com.ssy.lingxi.pay.repository.eAccount.EAccountStatusRecordRepository;
import com.ssy.lingxi.pay.service.eAccount.IEAccountStatusService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * e账户
 * @author jw.chen
 * @version 2.0.0
 * @date 2021/12/2
 */
@Service
public class EAccountStatusServiceImpl implements IEAccountStatusService {

    @Resource
    private EAccountStatusRecordRepository eAccountStatusRecordRepository;

    /**
     * 查询e账户状态记录
     * @param allInPayId e账号id
     */
    @Override
    public List<EAccountStatusRecord> getEAccountStatusRecord(Long allInPayId){
        return eAccountStatusRecordRepository.findByAllInPayIdOrderByCreateTimeAsc(allInPayId);
    }

    /**
     * 查询e账户历史流转记录
     * @param id 主键id
     * @return
     */
    @Override
    public EAccountStatusRecord getEAccountById(Long id) {
        return eAccountStatusRecordRepository.findById(id).orElse(null);
    }

    /**
     * 保存记录
     * @param eAccountStatusRecord  参数
     */
    @Override
    public void saveEAccountStatusRecord(EAccountStatusRecord eAccountStatusRecord) {
        eAccountStatusRecordRepository.saveAndFlush(eAccountStatusRecord);
    }
}

